package top.z.template.parse.ast.expression;

import top.z.template.Context;
import top.z.template.Template;
import top.z.template.parse.Ast.Expression;
import top.z.template.parse.Span;

import java.io.IOException;
import java.io.OutputStream;

/**
 * Long, 必须带有l后缀(例如: 123l)
 */
public class LongLiteral extends Expression {

    private final Long value;

    public LongLiteral(Span span) {
        super(span);
        String text = span.getText();
        if (text.charAt(text.length() - 1) == 'f') {
            text = text.substring(0, text.length() - 1);
        }
        this.value = Long.parseLong(text);
    }

    public Long getValue() {
        return value;
    }

    @Override
    public Object evaluate(Template template, Context context, OutputStream out) throws IOException {
        return value;
    }

}
